/*
 * @lc app=leetcode.cn id=925 lang=javascript
 *
 * [925] 长按键入
 */

// @lc code=start
/**
 * @param {string} name
 * @param {string} typed
 * @return {boolean}
 */
var isLongPressedName = function(name, typed) {   let j=0,i=0
    if(name[name.length-1]!==typed[typed.length-1])return false
    for(;i<name.length&&j<typed.length;){
        if(name[i]==typed[j]){
            i++
        }
        j++
        if(typed[j]!==name[i]&&typed[j]!==name[i-1]){return false}
    }
    return i===name.length
};
// @lc code=end

